/* eslint-disable @typescript-eslint/no-explicit-any */
import type { FormProps as BaseFormProps } from 'ant-design-vue'
import type { NamePath, RuleObject } from 'ant-design-vue/lib/form/interface'

export type Rule = RuleObject & {
  trigger?: 'blur' | 'change' | ['change', 'blur']
}

export type InputTag = 'a-input' | 'a-select' | 'a-cascader'
export type InputChildTag = 'a-select-option'

/**
 * 输入框子组件属性
 */
export interface InputChild {
  tag: InputChildTag
  content?: string
  props: any
}

/**
 * 表单项配置
 */
export interface FormItemOption<T = any> {
  /**
   * 表单项属性
   */
  formProps: { label: string | JSX.Element; name: keyof T }
  /**
   * 输入框配置
   */
  inputOption: {
    /**
     * 输入框tag
     */
    tag: InputTag
    /**
     * 输入框属性
     */
    props: any
    children?: InputChild[]
  }
}

export interface FormActionType {
  resetFields: () => Promise<void>
  clearValidate: (name?: string | string[]) => Promise<void>
  validateFields: (nameList?: NamePath[]) => Promise<any>
  validate: (nameList?: NamePath[]) => Promise<any>
  scrollToField: (name: NamePath, options?: ScrollOptions) => Promise<void>
}

export type FormProps = BaseFormProps & { model: { [key: string]: any } }
